﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace Demo
{
	public partial class DemoForm : Form
	{
		public DemoForm()
		{
			InitializeComponent();

			_API = new SpotifyAPI.SpotifyAPI();
			_API.IsPlayingChanged += new EventHandler(_API_TrackChanged);
			_API.TrackChanged += new EventHandler(_API_TrackChanged);
			_API.Initialize();

		}

		void _API_TrackChanged(object sender, EventArgs e)
		{
			if (_API.IsPlaying)
			{
				lInfo.Text =
					"Title: " + _API.Track.Artist + " - " + _API.Track.Title + "\r\n" +
					"Album: " + _API.Track.TrackNo + "-" + _API.Track.Album + " (" + _API.Track.Year + ")\r\n" +
					"Length: " + new TimeSpan(0, 0,_API.Track.SongLength).ToString();
			}
			else
				lInfo.Text = "Paused";

			if (_API.IsPlaying)
				uxPlayPause.Text = "Pause";
			else
				uxPlayPause.Text = "Play";
		}

		SpotifyAPI.SpotifyAPI _API;

		private void bNext_Click(object sender, EventArgs e)
		{
			_API.Next();
		}

		private void bPrev_Click(object sender, EventArgs e)
		{
			_API.Previous();
		}

		private void bPlayPause_Click(object sender, EventArgs e)
		{
			_API.PlayPause();
		}

		private void uxStop_Click(object sender, EventArgs e)
		{
			_API.Stop();
		}

		private void uxVolumeUp_Click(object sender, EventArgs e)
		{
			_API.VolumeUp();
		}

		private void uxVolumeDown_Click(object sender, EventArgs e)
		{
			_API.VolumeDown();
		}

		private void uxMute_Click(object sender, EventArgs e)
		{
			_API.Mute();
		}

	}
}
